﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Dycox.Validation
{
    [AttributeUsage(AttributeTargets.Property, AllowMultiple = false)]
    public class RequiredValidatorAttribute : ValidatorAttribute
    {
        public RequiredValidatorAttribute()
            : this(false)
        {

        }

        public RequiredValidatorAttribute(bool trimWhiteSpaces)
            : base(trimWhiteSpaces)
        {

        }

        protected override Validator CreateValidator(object[] parameters, System.ComponentModel.ITypeDescriptorContext context)
        {
            return new RequiredValidator() { TrimWhiteSpaces = (bool)parameters[0] };
        }
    }
}
